<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const p1 = new Promise((resolve,reject)=>{
            try{
                console.log('请求数据A');
                throw new Error('cuowu')
                setTimeout(() => {
                    console.log('请求A结束');
                    resolve('返回的数据A')
                },1000);
            }catch(e){
                reject(e.message)
            }
            
        })
        const p2 = new Promise((resolve,reject)=>{
            try{
                console.log('请求数据B');
                throw new Error('cuowu')
                setTimeout(() => {
                    console.log('请求B结束');
                    resolve('返回的数据B')
                },1500);
            }catch(e){
                reject(e.message)
            }
            
        })
        const p3 = new Promise((resolve,reject)=>{
            try{
                console.log('请求数据C');
                throw new Error('cuowu')
                setTimeout(() => {
                    console.log('请求C结束');
                    resolve('返回的数据C')
                },2500);
            }catch(e){
                reject(e.message)
            }
            
        })

        console.log(Promise.all([p1,p2,p3]));  // 返回p1.p2.p3成功的值  本质是个数组，当有错误的时候返回错误的信息 全部正确才返回数组 错哪个返回哪个错误的信息 有一个错对应的promiseState 值就是reject
        console.log(Promise.allSettled([p1,p2,p3]));//必然返回一个由对象构成的数组，无论错误还是正确都是有信息对应 无论怎样 状态都是 fulfilled
        console.log(Promise.race([p1,p2,p3]))//找到最快改变状态一个 无论成功或者失败都是  会反应
        console.log(Promise.any([p1,p2,p3]))//找到最快成功哪一个  如果都不成功就报错  eg：AggregateError: All promises were rejected

    </script>
</body>
</html>